package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.item.client.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.support.BindingAwareModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李旭
 * @date 2021/11/19 10:29
 * @Description:
 *
 *   商品详情页面
 *
 *   页面渲染
 */
@Controller
public class ItemController {


    @Autowired
    private ItemFeignClient itemFeignClient;

    //http://item.gmall.com  /100023014936.html
    //进入商品详情页面
    @GetMapping("/{skuId}.html")
    public String toItemPage(@PathVariable Long skuId, Map map){
        Map result = itemFeignClient.getItem(skuId);
        //将上面的resultMap直接整个全部放到新的Map中
        map.putAll(result);//K V
        //页面渲染
        return "item/index";
    }
}
